package cn.connectivity.plugin.util;

import com.intellij.notification.*;
import com.intellij.openapi.ui.MessageType;
import lombok.experimental.UtilityClass;
import org.jetbrains.annotations.NotNull;

import javax.swing.event.HyperlinkEvent;
import java.util.UUID;

@UtilityClass
public class Notify {

    public void info(String msg) {
        NotificationGroup notificationGroup = new NotificationGroup(UUID.randomUUID().toString(), NotificationDisplayType.BALLOON, false);
        Notification notification = notificationGroup.createNotification(msg, MessageType.INFO);
        Notifications.Bus.notify(notification);
    }

    public void error(String title, String msg) {
        NotificationGroup notificationGroup = new NotificationGroup(UUID.randomUUID().toString(), NotificationDisplayType.BALLOON, false);
        Notifications.Bus.notify(notificationGroup.createNotification(title, msg, NotificationType.ERROR, new NotificationListener.Adapter() {
            @Override
            protected void hyperlinkActivated(@NotNull Notification notification, @NotNull HyperlinkEvent hyperlinkEvent) {

            }
        }));
    }
}
